package com.xiyu.service.controller.admin.fee;
import com.xiyu.service.vo.fee.feeDeposit.FeeDepositSingleGetByElderIdOutput;
import com.xiyu.service.vo.fee.feeDeposit.FeeDepositPageQueryDetailOutput;
import com.xiyu.service.vo.fee.feeDeposit.FeeDepositPageQueryDetailInput;
import com.xiyu.service.vo.fee.feeDeposit.FeeDepositCreateInput;
import com.xiyu.service.vo.fee.feeDeposit.FeeDepositPageQueryOutput;
import com.xiyu.service.vo.fee.feeDeposit.FeeDepositPageQueryInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;
import java.util.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.fee.FeeDepositService;

@Tag(name = "押金管理")
@RestController
@RequestMapping("/fee/fee-deposit")
@Validated
public class FeeDepositController {

    @Resource
    private FeeDepositService feeDepositService;

    @GetMapping("/page-query")
    @Operation(summary = "分页查询押金")
    @PreAuthorize("@ss.hasPermission('fee:deposit:query')")
    public CommonResult<PageResult<FeeDepositPageQueryOutput>> pageQuery(@Valid FeeDepositPageQueryInput inputVO) {
        return success(feeDepositService.pageQuery(inputVO));
    }

    @PostMapping("/create")
    @Operation(summary = "交押金")
    @PreAuthorize("@ss.hasPermission('fee:deposit:create')")
    public CommonResult<Long> create(@Valid @RequestBody List<FeeDepositCreateInput> inputVO) {
        return success(feeDepositService.create(inputVO));
    }


    @GetMapping("/page-query-detail")
    @Operation(summary = "分页查询押金详情")
    @PreAuthorize("@ss.hasPermission('fee:deposit:queryDetail')")
    public CommonResult<PageResult<FeeDepositPageQueryDetailOutput>> pageQueryDetail(@Valid FeeDepositPageQueryDetailInput inputVO) {
        return success(feeDepositService.pageQueryDetail(inputVO));
    }

    @PostMapping("/confirm")
    @Operation(summary = "确认缴费")
    @PreAuthorize("@ss.hasPermission('fee:deposit:confirm')")
    @Parameter(name = "id", description = "押金详情主键ID", example = "")
    public CommonResult<Boolean> confirm(@RequestParam("id") Long id) {
        return success(feeDepositService.confirm(id));
    }

    @GetMapping("/single-get-by-elder-id")
    @Operation(summary = "根据老人ID获取单个押金")
    @Parameter(name = "id", description = "老人基本信息主键ID", example = "")
    public CommonResult<FeeDepositSingleGetByElderIdOutput> singleGetByElderId(@RequestParam("id") Long id) {
        return success(feeDepositService.singleGetByElderId(id));
    }

}
